package com.AAA.service.Impl.sds;

import com.AAA.entity.*;
import com.AAA.entity.sds.TTestRecondSds;
import com.AAA.entity.sds.TTestRecondSds1;
import com.AAA.service.sds.TTestRecondSdsService;
import com.AAA.dao.sds.TTestRecondSdsMapper;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

/**
 * (TTestRecondSds)表服务实现类
 *
 * @author makejava
 * @since 2022-11-04 16:23:26
 */
@Service
public class TTestRecondSdsServiceImpl implements TTestRecondSdsService {
   @Autowired
   private TTestRecondSdsMapper mapper;

   @Override
   public boolean add(HttpServletRequest request, HttpSession session) {
      User user = (User) session.getAttribute("user");
      String createby= user.getUsername();
      String recond = request.getParameter("recond");
      String remark = request.getParameter("remark");
      String username = request.getParameter("username");
      Integer rid= mapper.selectridbyusername(username);
      Integer pid= mapper.selectpidbyrid(username);
      Date createtime= new Date();
      boolean all=mapper.insertall(createby,recond,remark,rid,pid,createtime);
      return all;
   }
   @Override
   public PageInfo selectall(MyPage myPage, TTestRecondSds1 tTestRecondSds) {
      PageHelper.startPage(myPage.getPage(), myPage.getLimit());
      List<TTestRecondSds1> select = mapper.selectmohu(tTestRecondSds);
      PageInfo pageInfo = new PageInfo<>(select);
      return pageInfo;
   }
//修改
   @Override
   public boolean update(TTestRecondSds tTestRecondSds){
      tTestRecondSds.setUpdatetime(new Date());
      int all=mapper.updateByPrimaryKeySelective(tTestRecondSds);
      if (all>0){
         return true;
      }else {
         return false;
      }

   }
   //删除
   @Override
   public Integer delete(Integer id) {
      //deleteByPrimaryKey 获取实体类定义的id值  进行删除
      return mapper.deleteByPrimaryKey(id);

   }


   @Override
   public Integer selectidbyusername(String username) {
      Integer id=mapper.selectidbyusername(username);
      return id;
   }

   @Override
   public Integer selectusernameidbyusername(Integer id) {
      Integer usernameid=mapper.selectusernameidbyusername(id);
      return usernameid;
   }



}